<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>知识问答系统</title>
    <link rel="stylesheet" href="/css/bootstrap.css">
    <link rel="stylesheet" href="/styles/all.css">
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top navbar-inverse">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/">知识管理系统</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="/ask">提问</a></li>
                {{if user}}
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{user}}<span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="/user">个人资料</a></li>
                        <li role="separator" class="divider"></li>
                        <li class="quit"><a href="/signout">退出</a></li>
                    </ul>
                </li>
                {{else}}
                <li><a href="/signin">登录</a></li>
                {{/if}}
                <li><a href="/register">注册</a></li>
            </ul>
        </div>
    </div>
</nav>
<!--数据直接从后端来到前端了-->
<div class="container questions">
    {{each questions as q}}
    <div class="media" onclick="location.href='/answer/{{q.time | ms}}'">
        <div class="media-left">
            <a>
                <img class="media-object" src="/uploads/{{q.petname}}.jpg" onerror="this.src='/images/user.png'">
            </a>
        </div>
        <div class="media-body">
            <h4 class="media-heading">{{q.petname}}</h4>
            {{q.content}}
            <div class="media-footing">
                {{q.time | formatTime}}
            </div>
        </div>
    </div>
    {{each q.answers as a}}
    <div class="media media-child">
        <div class="media-body">
            <h4 class="media-heading">{{a.petname}}</h4>
            {{a.content}}
            <div class="media-footing">
                {{a.time | formatTime}}
            </div>
        </div>
        <div class="media-right">
            <a>
                <img class="media-object" src="/uploads/{{a.petname}}.jpg" onerror="this.src='/images/user.png'">
            </a>
        </div>
    </div>
    {{/each}}
    {{/each}}
</div>
</body>
</html>

<script src="/js/jquery.js"></script>
<script src="/js/bootstrap.js"></script>
<script src="/js/jquery.cookie.js"></script>
<script src="/scripts/public.js"></script>
